#include "CardType.h"
#include "CardTypeData.h"
#include "CardTypeManager.h"
#include "PokerData.h"
#include <iostream>

Flush::Flush() {
}

Flush::~Flush() {
}

CardTypeData Flush::getCardType(const PokerData & data) const{
  vector<Poker> pokers = data.getPokers();
  vector<Poker> flushs = PokerData::getFlushData(pokers);
  if (flushs.size() > 4) {
    PokerData::sortData(flushs);
    CardTypeData cardTypeData;
    cardTypeData.type = CardType::Flush;
    cardTypeData.first = flushs.at(0).value;
    cardTypeData.second = flushs.at(1).value;
    cardTypeData.third = flushs.at(2).value;
    cardTypeData.fourth = flushs.at(3).value;
    cardTypeData.fifth = flushs.at(4).value;
    return cardTypeData;
  }
  return getNextType()->getCardType(data);
}

const CardType * Flush::getNextType() const {
  return CardTypeManager::sharedCardTypeManager()->getCardType(CardType::Straight);
}
